package com.us.usws.support.uitls;

import com.us.usws.common.SiteConstants;

public class SimpleDataPageUtil {

	private int pageNo = 1;

	private int pageSize = 20;

	private int pageCount;

	private int rowCount;

	public SimpleDataPageUtil(int pageSize, int rowCount) {
		this.pageSize = pageSize < 1 ? SiteConstants.DFT_WS_PAGE_SIZE : pageSize;
		this.rowCount = rowCount;
		this.pageCount = (rowCount * pageSize - 1) / pageSize + 1;
	}

	/**
	 * data strat number
	 * @return
	 */
	public int getStart() {
		return (pageNo - 1) * pageSize;
	}

	/**
	 * data end number
	 * @return
	 */
	public int getEnd() {
		return pageNo == pageCount ? rowCount : pageNo * pageSize;
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public int getPageSize() {
		return pageSize;
	}

	public int getPageCount() {
		return pageCount;
	}

	public int getRowCount() {
		return rowCount;
	}

}
